<template>
  <div class="card_container">
    <div class="card" v-for="(card, index) in cardList" :key="index">
      <div class="info">
        <div class="title">
          <span class="text" :style="getBackgroundStyle(card.type)">{{ card.typeName }}</span>
          {{ card.title }}
        </div>
        <div class="details">
          <ImgT src="/imgs/club/jinbi.png" class="jinbi" alt="" />
          <span class="price">{{ card.price }}</span>
        </div>
      </div>
      <div class="players_box">
        <span class="players">
          <ImgT src="/imgs/club/people.png" class="icon_player" alt="" />
          <span>{{ card.players }}</span>
        </span>
      </div>
      <div class="action">
        <div class="button">
          <div>
            <p>买入</p>
            <p class="price">{{ card.buyIn }}</p>
          </div>
          <ImgT src="/imgs/club/arrow.png" class="arrow" alt="" />
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import {  ref } from 'vue';

const cardList: any = ref([
  { title: '德州快乐小伙伴', type: 1, typeName: '经典德州', price: '$ 0.25/0.6', players: '3/8', buyIn: 200 },
  { title: '欢乐德州桌', type: 2, typeName: '双公德州', price: '$ 1.5/3.0', players: '5/8', buyIn: 500 },
  { title: '激情桌牌', type: 3, typeName: '五河德州', price: '$ 0.5/1.0', players: '2/8', buyIn: 100 },
  { title: '大牌桌', type: 4, typeName: '皇家德州', price: '$ 2.0/4.0', players: '7/8', buyIn: 1000 },
  { title: '短牌', type: 5, typeName: '短牌德州', price: '$ 2.0/4.0', players: '6/8', buyIn: 1500 },
]);

// 动态计算背景样式
const getBackgroundStyle = (type: number) => {
  switch (type) {
    case 1:
      return {
        background: 'linear-gradient(90deg, #83FFAA -9.41%, #0FC953 87.44%)',
        WebkitBackgroundClip: 'text',
        WebkitTextFillColor: 'transparent',
      };
    case 2:
      return {
        background: 'linear-gradient(91deg, #5FFF74 4.63%, #0AC51C 82.74%)',
        WebkitBackgroundClip: 'text',
        WebkitTextFillColor: 'transparent',
      };
    case 3:
      return {
        background: 'linear-gradient(90deg, #A6E942 12.19%, #58DB3E 69.95%)',
        WebkitBackgroundClip: 'text',
        WebkitTextFillColor: 'transparent',
      };
    case 4:
      return {
        background: 'linear-gradient(89deg, #3DE6A5 5.3%, #06AE3E 89.84%)',
        WebkitBackgroundClip: 'text',
        WebkitTextFillColor: 'transparent',
      };
    case 5:
      return {
        background: 'linear-gradient(89deg, #68B1FF -5.33%, #1F6BDE 84.84%)',
        WebkitBackgroundClip: 'text',
        WebkitTextFillColor: 'transparent',
      };
    default:
      return {};
  }
};
</script>

<style scoped lang="scss">
.card_container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 347px;
  margin: 0 auto;

  .card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 347px;
    height: 60px;
    border-radius: 10px;
    padding: 0 0 0 15px;
    background: url(/imgs/club/add_club_bg.png) no-repeat;
    background-size: 100% 100%;
    box-shadow: 0.5px 0.5px 1px 0px #2E296B inset;

    .info {
      width: 145px;
      display: flex;
      flex-direction: column;
      justify-content: center;

      .title {
        color: #FFF;
        font-size: 12px;
        font-weight: 500;
        
        .text {
          font-family: HYYaKuHeiW;
          font-size: 14px;
          font-weight: 400;
        }
      }

      .details {
        // display: flex;
        // justify-content: space-between;
        margin-top: 5px;
        font-size: 14px;
        color: #a0a0b0;

        .jinbi {
          width: 16px;
          height: 16px;
          margin-right: 8px;
          vertical-align: sub;
        }

        .price {
          margin-right: 15px;
          color: #C6C4F5;
        }
      }
    }

    .players_box {

      .players {
        .icon_player {
          width: 20px;
          height: 20px;
          margin: 0 auto;
          display: block;
        }

        span {
          font-size: 14px;
          color: #C6C4F5;
        }
      }
    }

    .action {
      display: flex;
      align-items: center;
      width: 90px;
      height: 100%;
      background: rgba(250, 250, 250, 0.21);
      border-radius: 8px;
      padding: 5px 15px;

      .button {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        border-radius: 8px;
        color: #ffffff;
        font-size: 14px;

        .price {
          color: #C6C4F5;
        }
      }

      .arrow {
        width: 16px;
        height: 16px;
        margin-left: 15px;
      }
    }
  }
}
</style>